{% extends 'admin/base.html' %}
{% import "admin/_macros.html" as macros %}

{% block title %}
    Blog_mini -插件管理
{% endblock %}

{% block admin_content %}
    <div class="row">
        <div class="col-md-1"></div>
        <div class="col-md-10">
            <div class="panel">
                <div class="panel-heading">
                    <h3 class="panel-title">插件管理</h3>
                </div>
                <div class="panel-body">
                    <div class="entry-box custom-blog-plugin">
                        <p><span class="glyphicon glyphicon-wrench"></span>插件总数：<span
                                class="badge">{{ Plugin.query.count() }}</span></p>
                        <div class="blog-plugin-box">
                            <div class="blog-plugin" id="blogPlugin">
                                <table class="table table-striped table-hover">
                                    <thead>
                                    <tr class="table-header">
                                        <th>序号</th>
                                        <th>插件名称</th>
                                        <th>备注</th>
                                        <th>排序</th>
                                        <th>启用</th>
                                        <th>修改</th>
                                        <th>删除</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    {% for plugin in plugins %}
                                        <tr>
                                            <td>{{ plugin.order }}</td>
                                            <td>{{ plugin.title }}</td>
                                            <td>{{ plugin.note }}</td>
                                            <td>
                                                <a class="btn sort-up" title="升序"
                                                   href="{{ url_for('admin.plugin_sort_up', id=plugin.id, page=page) }}">
                                                    <span class="glyphicon glyphicon-circle-arrow-up"></span>
                                                </a>
                                                <a class="btn sort-down" title="降序"
                                                   href="{{ url_for('admin.plugin_sort_down', id=plugin.id, page=page) }}">
                                                    <span class="glyphicon glyphicon-circle-arrow-down"></span>
                                                </a>
                                            </td>
                                            <td>
                                                {% if plugin.disabled == True %}
                                                    <a class="btn btn-sm btn-warning comment-handle-admin enabled-blog-plugin-btn"
                                                       title="启用插件"
                                                       href="{{ url_for('admin.enable_plugin', id=plugin.id, page=page) }}">
                                                        <span class="glyphicon glyphicon-remove-sign"></span>
                                                    </a>
                                                {% else %}
                                                    <a class="btn btn-sm btn-success comment-handle-admin disabled-blog-plugin-btn"
                                                       title="禁用插件"
                                                       href="{{ url_for('admin.disable_plugin', id=plugin.id, page=page) }}">
                                                        <span class="glyphicon glyphicon-ok-sign"></span>
                                                    </a>
                                                {% endif %}
                                            </td>
                                            {% if plugin.content != 'system_plugin' %}
                                                <td>
                                                    <a class="btn" title="修改插件信息"
                                                       href="{{ url_for('admin.edit_plugin', id=plugin.id, page=page) }}">
                                                        <span class="glyphicon glyphicon-edit"></span>
                                                    </a>
                                                </td>
                                                <td>
                                                    <a class="btn btn-sm btn-default delete-blog-plugin" title="删除插件"
                                                       onclick="delPluginCfm('{{ url_for('admin.delete_plugin', id=plugin.id, page=page) }}')">
                                                        <span class="glyphicon glyphicon-trash"></span>
                                                    </a>
                                                </td>
                                            {% else %}
                                                <td></td>
                                                <td></td>
                                            {% endif %}
                                        </tr>
                                    {% endfor %}
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="pagination">
                            {{ macros.pagination_widget(pagination, endpoint) }}
                        </div>
                    </div>

                    <!-- 信息删除确认: For delete a plugin confirm -->
                    <div class="modal fade" id="delPluginCfmModal">
                        <div class="modal-dialog">
                            <div class="modal-content message_align">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                            aria-hidden="true">×</span></button>
                                    <h4 class="modal-title">确认删除插件？</h4>
                                </div>
                                <div class="modal-body">
                                    <p>
                                        将该导航删除后不可恢复，您确认要删除吗？
                                    </p>
                                    <p>
                                        （提示：如果您只是不想显示该插件，可以将其禁用，而不必删除。）
                                    </p>
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                    <a onclick="" id="delPluginCfmClick" class="btn btn-success"
                                       data-dismiss="modal">确定</a>
                                </div>
                            </div><!-- /.modal-content -->
                        </div><!-- /.modal-dialog -->
                    </div><!-- /.modal -->
                </div>
            </div>
        </div>
    </div>

{% endblock %}
